@createConsent
Feature: Consent项目：创建consent

  # 处理参数
  Scenario Outline: [TC_createConsent_API_01_<SeqNumber>] 创建consent 处理参数
    Given Specify headers as below table
      | GroupId | <GroupId> |
    When Send API 'createConsent' with updated below fields
      | STEP_NAME             | createConsent                                                          |
      # [] 格式，新增一个内容
      | $.Data.temp           | {{add,temp2}}                                                          |
      # {} 格式，新增 key，value
      | $.Data                | {{put,Purpose,[test1,test2]}}                                          |
      | $.Data.type           | {{put,type1, {{json({"id":"id1"})}}}}                                  |
      | $.Data.ExpireDateTime | {{date(yyyy-MM-dd'T'HH:mm:ss,Asia/Riyadh,365)}}                        |
      # [] 格式，更新内容
      | $.Data.Permissions    | [AccountBasic,AccountsBalance]                                         |
      | $.Data.phone          | {{format(UPPER,{{date(yyyyMMdd)}}ab)}}{{format(SUBSTRING,Abc123,1,3)}} |
      | $.Data.username       | {{delete}}                                                             |
    Then Response status code should be 201
    Given Reset headers
    Given Specify headers as below table
      | ConsentId    | {{#createConsent.response.body.Data.ConsentId}} |
      | RequestPhone | {{#createConsent.request.body.Data.phone}}      |
    When Send API 'openidConfiguration' with updated below fields
      | STEP_NAME | testStep |
    Then Response status code should be 200
    * Assert below expression
      | actual                     | expected | relation |
      | {{#.response.body.issuer}} | <issuer> | ==       |
    Examples:
      | SeqNumber | GroupId   | issuer                                |
      | 01        | TestGroup | https://apitest.cacho.com/openbanking |

  # 处理 JWT
  Scenario Outline: [TC_createConsent_API_02_<SeqNumber>] 创建 Consent 处理 jwt
    And Read API 'createConsent' payload with updated below fields
      | JWT_scope   | payments  |
      | JWT_payload | <payload> |
    Given Specify headers as below table
      | GroupId  | <GroupId>          |
      | JwtToken | {{jwt(<GroupId>)}} |
    When Send API 'createConsent' with updated below fields
      | STEP_NAME             | createConsent                                   |
      | $.Data.type           | {{put,type1, {{json({"id":"id1"})}}}}           |
      | $.Data.ExpireDateTime | {{date(yyyy-MM-dd'T'HH:mm:ss,Asia/Riyadh,365)}} |
    Then Response status code should be 201
    Examples:
      | SeqNumber | GroupId | payload              |
      | 01        | GroupId | {"sessionId":"test"} |

    # 处理 JWS
  Scenario Outline: [TC_createConsent_API_03_<SeqNumber>] 创建 Consent 处理 JWS
    And Read API 'createConsent' payload with updated below fields
      | $.Data.type           | {{put,type1, {{json({"id":"id1"})}}}}           |
      | $.Data.ExpireDateTime | {{date(yyyy-MM-dd'T00:00:00',Asia/Riyadh,365)}} |
    Given Specify headers as below table
      | GroupId | <GroupId>          |
      | JWS     | {{jws(<GroupId>)}} |
    When Send API 'createConsent' with updated below fields
      | STEP_NAME             | createConsent                                   |
      | $.Data.type           | {{put,type1, {{json({"id":"id1"})}}}}           |
      | $.Data.ExpireDateTime | {{date(yyyy-MM-dd'T00:00:00',Asia/Riyadh,365)}} |
    Then Response status code should be 201
    Examples:
      | SeqNumber | GroupId |
      | 01        | GroupId |

  # POST 请求，body 传 JWT
  Scenario Outline: [TC_createConsent_API_04_<SeqNumber>] 创建 Consent 处理 jwt
    Given Specify headers as below table
      | GroupId   | <GroupId> |
      | BodyIsJWT | no        |
    When Send API 'createConsent' with updated below fields
      | STEP_NAME             | createConsent                                   |
      | $.Data.type           | {{put,type1, {{json({"id":"id1"})}}}}           |
      | $.Data.ExpireDateTime | {{date(yyyy-MM-dd'T'HH:mm:ss,Asia/Riyadh,365)}} |
    Then Response status code should be 201
    Examples:
      | SeqNumber | GroupId |
      | 01        | GroupId |

  # Get 请求，headers 传 JWT
  Scenario Outline: [TC_getConsent_API_01_<SeqNumber>] get Consent 处理 jwt
    Given Specify headers as below table
      | GroupId | <GroupId> |
    When Send API 'getConsent' with updated below fields
      | STEP_NAME | getConsent |
      | ConsentId | 2025-04-14 |
    Then Response status code should be 200
    Examples:
      | SeqNumber | GroupId |
      | 01        | GroupId |